package Operation;

import Student.Student;

import java.util.Iterator;
import java.util.Scanner;
import java.util.TreeMap;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ling
 * Date: 2022-04-16
 * Time: 20:37
 */
public class FindOpreation implements IOperation{
    @Override
    public void work(TreeMap<Student,String> treeMap) {
        System.out.println("信息查询");
        Scanner scanner=new Scanner(System.in);
        Iterator<Student>iterator=treeMap.keySet().iterator();
        System.out.println("请输入你要查找人的姓名");
        String name=scanner.nextLine();
        while(iterator.hasNext()){
            Student key=iterator.next();
            if(name.equals(key.getName())){
                System.out.println("信息如下");
                System.out.println(key);
                return;
            }
        }
        System.out.println("查询无此人");
    }
}
